<template>
  <div class="vm-common-item-list">
    <!-- 需求信息 -->
    <keep-alive>
      <vm-index-require-list  v-if="c_cartgoryType == 'requireInfo'" ref="requireModule"></vm-index-require-list>
    </keep-alive>
    <!-- 项目信息 -->
    <keep-alive>
      <vm-index-project-list v-if="c_cartgoryType == 'projectInfo'" ref="projectModule"></vm-index-project-list>
    </keep-alive>
  </div>
</template>

<script>
  import vmIndexRequireList from '@/components/index/vm-index-require-list.vue'
  import vmIndexProjectList from '@/components/index/vm-index-project-list.vue'
  export default {
    data () {
      return {
        c_cartgoryType : this.cartgoryType || 'requireInfo', // 分类类型
      }
    },
    created (){},
    mounted () {
      // 分类导航改变
      this.initData();
      this.$root.Bus.$on('changeNavType', (cartgoryType) => {
        this.c_cartgoryType = cartgoryType;
      });
    },
    methods: {
      initData () {
        // 重新加载需求信息
        this.$refs.requireModule.requirePage = 0;
        this.$refs.requireModule.listType = 0;
        this.$refs.requireModule.allLoaded = false;
        this.$refs.requireModule.getRequireInfoData(true);
      }
    },
    updated () {
      if ( this.c_cartgoryType == 'projectInfo' ){
        // 重新加载项目信息
        this.$refs.projectModule.projectPage = 0;
        this.$refs.projectModule.projectPage ++;
        this.$refs.projectModule.allLoaded = false;
        this.$refs.projectModule.getProjectInfoData(true);
      } else if ( this.c_cartgoryType == 'requireInfo' ) {
        // 重新加载需求信息
        this.$refs.requireModule.requirePage = 0;
        this.$refs.requireModule.listType = 0;
        this.$refs.requireModule.allLoaded = false;
        this.$refs.requireModule.getRequireInfoData(true);
      }
    },
    props:['cartgoryType'],
    components: {
      'vm-index-require-list' : vmIndexRequireList,
      'vm-index-project-list': vmIndexProjectList
    }
  }
</script>

<style lang="scss">

</style>
